Part Number Hot Search : 
W541C261 BZ5221 FDMD8630 MAX232 TK61023 4N06L 222M35 IDM25PH5
Product Description
Full Text Search
 

To Download AN591 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  application note j.nicolai a AN591 / 03,93 input capture with st62 auto-reload timer figure 1. auto-reload timer block diagram introduction this note presents how to use the auto-reload timer (artimer) of the st62 to measure durations or fre- quencies of an input signal. auto-reload timer description this timer is an 8 bit timer/counter with prescaler. it includes auto-reload pwm, capture and compare ca- pability with one input and one output pins. it can be controlled by the following registers (8 bit): - mode control register (mc) - status registers (sc0, sc1) - load register (lr) - incremental counter register (tc) - compare register (cp) - reload/capture register (rc) it can also wake-up the mcu from wait mode and exit from stop mode if an external event is present on the input pin. the prescaler ratio can be programmed to choose the timer input frequency f in (see table 1). 1/4
bit 0 reg. sc1 ps2 ps1 ps0 prescaler ratio 0 000 1 0 001 2 0 010 4 0 011 8 0 100 16 0 101 32 0 110 64 0 111 128 1 000 3 1 001 6 1 010 12 1 011 24 1 100 48 1 101 96 1 110 192 1 111 384 table 1. prescaler programming ratio capture mode with reset this can be used to measure time durations or fre- quencies.this mode is used to measure the time elapsed between two edges of an external signal: two rising edges, two falling edges, or one rising and one falling if the configuration of the timer is modified after the first edge detected. the minimum duration of one signal to measure depends on the cpu clock and on the required precision. with a 8mhz quartz crystal, a signal of 8 m s duration can be measured with a resolution of 1/64. example: lets measure the time elapsed between two rising edges on timin: the prescaler ratio must be programmed accord- ing to the expected duration to measure. in this ex- ample it is programmed to: prescaler ratio = 4, clock source = cpu clock. (in case the duration ex- pected can be longer than the 255 count span of the tc count register, the overflow interrupt can be used to increment a ram variable, used as the most significant part of the result). in the program example, waiting for the edge on timin is made by a software loop (jrr 2, sc0, wt_edge), but it is also possible to use the external event interrupt to read the result immediately after the edge without loading the rest of the program. it is also possible to read the result directly from rc without waiting or using the interrupt, if the duration is required at an asynchronous time, not just after the edge. a input capture with artimer 2/4
;**************** accumulator ***************************** a .def 0ffh,0ffh,0ffh ;accumulator ;**************** ram variable **************************** period .def 084h,0ffh,0ffh ;elapsed time ;**************** a-r timer register set ****************** rc .def 0d9h,0ffh,0ffh ;reload/capture register cp .def 0dah,0ffh,0ffh ;compare register mc .def 0d5h,0ffh,0ffh ;mode control register sc0 .def 0d6h,0ffh,0ffh ;status/control register 0 sc1 .def 0d7h,0ffh,0ffh ;status/control register 1 lr .def 0dbh,0ffh,0ffh ;load register ;========================================================== ldi sc1,01000100b ;clock source = cpu, ;prescaler ratio = 4, ;pull-up on timin disabled, ;capture on rising edge of timin ldi mc, 11000010b ;capture with reset, ints. disabled ;pwmout disabled, start timer ; . ; . normal program ; . ;now we want to know the elapsed time between last and ;next edge on timin: res 2, sc0 ;clear external event flag wt_edge jrr 2,sc0,wt_edge ;wait for edge on ti min, then ld a,rc ;read elapsed time from reload/capt ld period,a ;register into variable period program example the following figure shows the evolution of the contents of tc and rc during capture operation: a rising edge on timin results in copying the latest value of tc into rc, and clearing tc. afterwards, tc incre- ments at the selected clock rate until the next capture or until it reaches 255. in the latter case, it wraps to 0. in capture mode, tc always counts from 0 to 255, it is never loaded from the rc register. figure 2. tc and rc evolution a input capture with artimer 3/4
information furnished is believed to be accurate and reliable. however, sgs-thomson microelectronics assumes no responsability for the consequences of use of such information nor for any infringement of pat- ents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of sgs-thomson microelectronics. specifications mentioned in this publication are subject to change without notice. this publication supersedes and replaces all infor- mation previously supplied. sgs-thomson microelectronics products are not authorized for use as critical components in life support devices or systems without the express written approval of sgs-thomson microelectronics. ? 1994 sgs-thomson microelectronics - all rights reserved. purchase of i 2 c components by sgs-thomson microelectronics conveys a license under the philips i 2 c patent. rights to use these components in an i 2 c system is granted provided that the system conforms to the i 2 c standard specification as defined by philips. sgs-thomson microelectronics group of companies australia - brazil - france - germany - hong kong - italy - japan - korea - malaysia - malta - morocco - the netherlands singapore - spain - sweden - switzerland - taiwan - thailand - united kingdom - u.s.a. the software included in this note is for guidance only. sgs-thomson shall not be held liable for any direct, indirect or consequential damages with respect to any claims arising from use of the software. a input capture with artimer 4/4


▲Up To Search▲   

 
Price & Availability of AN591

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X